<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>

<body class="gray-bg">
        <div class="col-sm-10 col-sm-offset-1">
            <div class="wrapper wrapper-content animated fadeInUp">
                <div class="ibox">
                    <div class="ibox-content">  
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="m-b-md">
                                    <a href="project_detail.html#" class="btn btn-white btn-xs pull-right">编辑项目</a>
                                    <h2>正式党员详情</h2>
                                </div>
                                <!-- <dl class="dl-horizontal">
                                    <dt>状态：</dt>
                                    <dd>
                                    	<span th:if="${user.proposer.partyApplication == null || user.proposer.partyMemcon == null}" class="label label-warning">进行中</span>
                                    	<span th:if="${user.proposer.partyApplication != null && user.proposer.partyMemcon != null}" class="label label-primary">已完成</span>
                                    </dd>
                                </dl> -->
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-sm-5">
                                <dl class="dl-horizontal" th:object="${user}">
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>姓名：</dt>
                                    <dd th:text="*{userName}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>年龄：</dt>
                                    <dd th:text="*{age}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>性别：</dt>
                                    <dd th:switch="*{sex}">
                                    	<span th:case="0">男</span>
                                    	<span th:case="1">女</span>
                                    	<span th:case="2">未知</span>
                                    </dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>身份证号码：</dt>
                                    <dd th:text="*{idCardNo}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>邮箱：</dt>
                                    <dd th:text="*{email}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>电话号码：</dt>
                                    <dd th:text="*{phonenumber}">获取失败</dd>
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>备注：</dt>
                                    <dd th:if="*{remark != null}" th:text="*{remark}"></dd>
                                    <dd th:if="*{remark == null}" th:text="此人很懒"></dd>
                                </dl>
                            </div>
                            <div class="col-sm-6" id="cluster_info" th:object="${user.proposer}">
                                <dl class="dl-horizontal">
                                
									<dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>入党志愿书：</dt>
                                    <dd th:if="*{partyApplicaiton != null}" >
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=partyApplicaiton,fileName=*{partyApplicaiton})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=partyApplicaiton,fileName=*{partyApplicaiton})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
                                    <dd th:if="*{partyApplicaiton != null}" style="margin-top:10px;">
	                                	<input class="btn btn-warning" value="点击决议后的入党志愿书" onclick="upload(3)">
	                                </dd>
                                    
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>预备党员教育考察登记表：</dt>
                                    <dd th:if="*{prepareInvestigate != null}">
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=prepareInvestigate,fileName=*{prepareInvestigate})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=prepareInvestigate,fileName=*{prepareInvestigate})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
                                    <dd th:if="*{prepareInvestigate == null}">
	                               	<input class="btn btn-warning" value="点击上传文件" onclick="upload(1)">
                                    </dd>
                                    
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>转正申请书：</dt>
                                    <dd th:if="*{officialApplication != null}">
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=officialApplication,fileName=*{officialApplication})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=officialApplication,fileName=*{officialApplication})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
                                    <dd class="text-danger" th:if="*{officialApplication == null}"><h3>请通知预备党员递交转正申请书</h3></dd>
                                    
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>预备党员转正公示情况登记表：</dt>
                                    <dd th:if="*{prepareToofficialPublicity != null}">
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=prepareToofficialPublicity,fileName=*{prepareToofficialPublicity})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=prepareToofficialPublicity,fileName=*{prepareToofficialPublicity})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
                                    <dd th:if="*{prepareToofficialPublicity == null}">
	                               	<input class="btn btn-warning" value="点击上传文件" onclick="upload(2)">
                                    
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>思想汇报（五）：</dt>
                                    <dd th:if="*{reportFifth != null}">
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportFifth,fileName=*{reportFifth})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=reportFifth,fileName=*{reportFifth})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
                                    <dd class="text-danger" th:if="*{reportFifth == null}"><h3>请通知发展对象递交思想汇报</h3></dd>
                                    
                                    <dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>思想汇报（六）：</dt>
                                    <dd th:if="*{reportSixth != null}">
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportSixth,fileName=*{reportSixth})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=reportSixth,fileName=*{reportSixth})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
	                               	<dd class="text-danger" th:if="*{reportSixth == null}"><h3>请通知发展对象递交思想汇报</h3></dd>
	                               	
	                               	<dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>思想汇报（七）：</dt>
                                    <dd th:if="*{reportSeventh != null}">
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportSeventh,fileName=*{reportSeventh})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=reportSeventh,fileName=*{reportSeventh})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
	                               	<dd class="text-danger" th:if="*{reportSeventh == null}"><h3>请通知发展对象递交思想汇报</h3></dd>
	                               	
	                               	<dt>&nbsp;</dt><dd>&nbsp;</dd>
                                    <dt>思想汇报（八）：</dt>
                                    <dd th:if="*{reportEighth != null}">
                                    <a th:href="@{/module/proposer/review(userId=${user.userId},type=reportEighth,fileName=*{reportEighth})}" class="btn btn-success btn-xs fa fa-edit" th:text="预览"></a>
                                    <a th:href="@{/module/proposer/download(userId=${user.userId},type=reportEighth,fileName=*{reportEighth})}" class="btn btn-success btn-xs fa fa-edit" th:text="下载"></a>
                                    </dd>
	                               	<dd class="text-danger" th:if="*{reportEighth == null}"><h3>请通知发展对象递交思想汇报</h3></dd>
                                                       
                                </dl>
                            </div>
                        </div>
                        <div class="row">&nbsp;</div>
                        <!-- <div class="row">
                            <div class="col-sm-12">
                                <dl class="dl-horizontal">
                                    <dt>当前进度</dt>
                                    <dd>
                                        <div class="progress progress-striped active m-b-sm">
				                          	<div th:if="${user.proposer.partyApplication == null} and ${user.proposer.partyMemcon == null}" style="width: 00%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="35" role="progressbar" class="progress-bar progress-bar-success">
                                				<span class="sr-only">0% Complete (success)</span>
                            				</div>  
											<div th:if="${user.proposer.partyApplication != null} and ${user.proposer.partyMemcon == null}" style="width: 40%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="35" role="progressbar" class="progress-bar progress-bar-danger">
                                				<span class="sr-only">40% Complete (success)</span>
                            				</div>  
                            				<div th:if="${user.proposer.partyApplication != null} and ${user.proposer.partyMemcon != null}" style="width: 100%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="35" role="progressbar" class="progress-bar progress-bar-primary">
                                				<span class="sr-only">100% Complete (success)</span>
                            				</div>                                        
                            			</div>
                                        <small>当前已完成进度的 <strong id="text">999%</strong></small>
                                    </dd>
                                </dl>
                            </div>
                        </div> -->
                        <div class="row">&nbsp;</div>
                        <div class="row">&nbsp;</div>
                        <div class="row text-center">
                        	<a type="button" href="javascript:" onclick="self.location=document.referrer;" class="btn btn-default btn-lg"><i class="fa fa-check"></i>&nbsp;返 回</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    
    <div th:include="include :: footer"></div>
    
    <!-- 甜甜的弹出层 -->
 	<script src="https://cdn.bootcss.com/limonte-sweetalert2/7.21.1/sweetalert2.all.js"></script>
    <script>
        $(document).ready(function () {

            $('#loading-example-btn').click(function () {
                btn = $(this);
                simpleLoad(btn, true)

                // Ajax example
                //                $.ajax().always(function () {
                //                    simpleLoad($(this), false)
                //                });

                simpleLoad(btn, false)
            });
        });

        function simpleLoad(btn, state) {
            if (state) {
                btn.children().addClass('fa-spin');
                btn.contents().last().replaceWith(" Loading");
            } else {
                setTimeout(function () {
                    btn.children().removeClass('fa-spin');
                    btn.contents().last().replaceWith(" Refresh");
                }, 2000);
            }
        }
    </script>
    
    <script th:inline="javascript">
        var userId= [[${user.userId}]];
        var partyApplication = [[${user.proposer.partyApplication}]];
        var partyMemcon = [[${user.proposer.partyMemcon}]];
        
        //进度条参数
        var progress;
        var type;
        if(partyMemcon == null){
        	if(partyApplication == null){
        		progress = "0%";
        	} else{
        		progress = "40%"
        	}
        }else{
        	progress = "100%";
        }
        console.log($('#text'));
        $('#text').html(progress);
        
    </script>
    
    <script>
    var prefix = "/module/proposer/";
    //文件上传
    function upload(value){
    	var path;
    	switch(value){
    	case 1:
	    	path = 'prepareInvestigate';
	    	break;
    	case 2:
	    	path = 'prepareToOfficialPublicity';
	    	break;		
	    case 3:
	   		path = 'partyApplicaiton';
	   		break;
    	};
		swal({
		  title: '提交文件',
		  input: 'file',
		    inputAttributes: {
    			accept: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword'
  			},
		  showCancelButton: true,
		  confirmButtonText: '确认提交',
		  showLoaderOnConfirm: true,
		  //提交前函数
		  preConfirm: function(file) {
		  	//校验函数
		    return new Promise(function(resolve, reject) { //返回resolve()为通过，reject()拒绝
		      //校验是否为doc或者docx
		        if (file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || value.type === 'application/msword') {
		          resolve();
		        } else {
		            swal(
				    '文件格式不正确！',
				    '只能上传doc或docx类型的文件',
				    'warning'
				  ); 
		        }
		    });
		  },
		  allowOutsideClick: false
		}).then(	//接着执行
		   function (file) {
		   //如果没有传入文件，而是点击取消，则不采取操作
		   if(file.value == undefined){
				return;		   
		   }
		   var fm = new FormData();
		   fm.append("file", file.value);
		   fm.append("userId", userId);
		   fm.append("type", path)
		   $.ajax({
		   		url: prefix + 'materials/upload',
		   		type: 'post',
		   		data: fm,
		   		dataType: 'json',
		   		contentType: false, //禁止设置请求类型
           		processData: false, //禁止jquery对DAta数据的处理,默认会处理
            	//禁止的原因是,FormData已经帮我们做了处理
		   		success: function(result){
		   			if(result.code === 0){
		   				swal(
						  '一切顺利',
						  result.msg,
						  'success'
						).then(function(){
							//刷新页面
							window.location.reload();
						});
						
		   			} else{
		   				swal(
						  '抱歉',
						  result.msg,
						  'error'
						)
		   			}
		   		},
		   		error: function(result){
		   				swal(
						  '抱歉',
						  '请求失败，请于网站管理员联系',
						  'error'
						)
		   		}
		   });
		}
		);
    }
    </script>

</body>
</html>
